<?php

class model_cart_Article {

    private $id;
    private $no;
    private $name;
    private $year;
    private $liter;
    private $price;
    private $qty;
    private $total;


    public function  __construct($id = null, $no = null, $name = null, $year = null, $liter = null, $price = null, $qty = null) {
        if ($id != null && $no != null && $name != null && $year != null && $liter != null && $price != null && $qty != null) {
            $this->id    = $id;
            $this->no    = $no;
            $this->name  = $name;
            $this->year  = $year;
            $this->liter = $liter;
            $this->price = $price;
            $this->qty   = $qty;
	        $this->calcTotal();
        }
    }

    public static function newInstance() {
        return new model_cart_Article();
    }

    public function reinit ($data) {
        $this->id    = $data['id'];
        $this->no    = $data['no'];
        $this->name  = $data['name'];
        $this->year  = $data['year'];
        $this->liter = $data['liter'];
        $this->price = $data['price'];
        $this->qty   = $data['qty'];
        $this->calcTotal();
        return $this;
    }

    public function dump () {
        return array(
            'id'    => $this->id,
            'no'    => $this->no,
            'name'  => $this->name,
            'year'  => $this->year,
            'liter' => $this->liter,
            'price' => $this->price,
            'qty'   => $this->qty
        );
    }

    public function setId($id) {
        $this->id    = $id;
        return $this;
    }

    public function setNo($no) {
        $this->no    = $no;
        return $this;
    }

    public function setName($name) {
        $this->name  = $name;
        return $this;
    }

    public function setYear($year) {
        $this->year  = $year;
        return $this;
    }

    public function setLiter($liter) {
        $this->liter = $liter;
        return $this;
    }

    public function setPrice($price) {
        $this->price = $price;
        $this->calcTotal();
        return $this;
    }

    public function setQty($qty) {
        $this->qty   = $qty;
        $this->calcTotal();
        return $this;
    }

    private function calcTotal () {
        $this->total = $this->price * $this->qty;
    }

    public function getId() {
        return $this->id;
    }

    public function getNo() {
        return $this->no;
    }

    public function getName() {
        return $this->name;
    }

    public function getYear() {
        return $this->year;
    }

    public function getLiter() {
        return $this->liter;
    }

    public function getPrice() {
        return $this->price;
    }

    public function getQty() {
        return $this->qty;
    }

    public function getTotal() {
        return $this->total;
    }

}

?>